<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>网页计算器</title>
</head>
<body>
<p>
    整数1：<input type="text" id="num1">
</p>
<p>
    整数2：<input type="text" id="num2">
</p>
<button onclick="count('+')">相加</button>
<button onclick="count('-')">相减</button>
<button onclick="count('*')">相乘</button>
<button onclick="count('/')">相除</button>
<p>
    结果：<input type="text" id="new">
</p>

<script>
    function count(e){
        var num1 = document.querySelector("#num1").value;
        var num2 = document.querySelector("#num2").value;
        num1 =Number(num1);
        num2 =Number(num2);
        switch (e){
            case '+':
                document.querySelector("#new").value = num1 + num2;
                break;
            case '-':
                document.querySelector("#new").value = num1 - num2;
                break;
            case '*':
                document.querySelector("#new").value = num1 * num2;
                break;
            case '/':
                document.querySelector("#new").value = num1 / num2;
                break;
        }
    }
</script>
</body>
</html>